#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 5e5 + 10, INF = 0x3f3f3f3f;

int n;
int a[N], b[N];
long long cnt;

void merge(int l, int r)
{
    if (l >= r)
        return;
    int mid = (l + r) >> 1;
    merge(l, mid);
    merge(mid + 1, r);

    int i = l, j = mid + 1, t = 0;
    while (i <= mid && j <= r) {
        if (a[i] > a[j]) {
            b[t++] = a[j++];
            cnt += mid - i + 1;
        } else
            b[t++] = a[i++];
    }
    while (i <= mid)
        b[t++] = a[i++];
    while (j <= r)
        b[t++] = a[j++];
    for (i = 0; i < t; i++)
        a[l + i] = b[i];
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    merge(0, n - 1);
    cout << cnt;
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}